/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Learning;

import edu.upf.grupE.Controller.AlbumController;
import edu.upf.grupE.Entities.Album;
import edu.upf.grupE.Entities.TextDescription;
import java.io.IOException;
import org.exolab.castor.xml.MarshalException;
import org.exolab.castor.xml.ValidationException;

/**
 *
 * @author Madhava Carrillo <madhava at me.com>
 */
public class PruebaProperties {

    /**
     *
     * @param args
     * @throws java.io.IOException
     * @throws java.lang.ClassNotFoundException
     */
    public static void main(String[] args) throws IOException, ClassNotFoundException, MarshalException, ValidationException {
        // Properties config = new Properties();
        // config.load(PruebaProperties.class.getClassLoader().getResourceAsStream("config/Queries.properties"));


//        DDBBManager gestorBD = DDBBManager.getInstance();
//        DDBBActionResult resultadoBD;
//
//
//        DDBBAction dbaction = new DDBBAction("Picture.getById", new String[]{"1"});


        //DDBBAction dbaction = new DDBBAction("Picture.getByOntologiesAndTag",new String[]{"lugar","europa"});

        //DDBBAction dbaction = new DDBBAction("Picture.getByOntologiesAndTag",new String[]{"lugar","africa"});

//        resultadoBD = gestorBD.execute(dbaction);
//
//        List result = resultadoBD.getResult();
//        Picture tmp = (Picture) result.get(0);
//
//        System.out.println(tmp.getId());
/*
        //Oscar: crear new picture
        Picture newpic = new Picture();
        FileDescriptor fileDescriptor = new FileDescriptor();
        fileDescriptor.setFormat("jpg");
        fileDescriptor.setPath("/cdcd/cdcdac/sdcsc/foto.jpg");
        fileDescriptor.setSize(23456);
        newpic.setFileDescriptor(fileDescriptor);
        newpic.setName("foto1!");
        TextDescription textDescription = new TextDescription();
        textDescription.setDescription("fotoooonummmsdfsdf se sdf sdfsdf");
        textDescription.addUserKeywords("tokio");
        Tag tag = new Tag();
        tag.setOntology("lugar");
        tag.setContent("tokio");
        textDescription.addTag(tag);
        newpic.setTextDescription(textDescription);
         */

        //end new picture

//        StringWriter xml = new StringWriter();
//        Marshaller marshaller = new Marshaller(xml);
//        marshaller.marshal(newpic);
//        String myXmlString = xml.toString();
//
//        System.out.println(myXmlString);
//        myXmlString=myXmlString.substring(myXmlString.indexOf("?>")+2);

        Album newAlbum = new Album();

        newAlbum.setName("ET");
        TextDescription td = new TextDescription();
        td.addUserKeywords("Micasa");
        td.setDescription("Peli de spilberg");
        newAlbum.setTextDescription(td);


        //System.out.println(myXmlString);

        AlbumController pc = new AlbumController();

        System.out.println(pc.createOrUpdate(newAlbum));

    //dbaction = new DDBBAction("Picture.updateById", new String[]{"1",myXmlString});

    //gestorBD.execute(dbaction);








//        List result = resultadoBD.getResult();
//
//        for (Object tmp : result) {
//            Picture pic = (Picture) tmp;
//            StringWriter xml = new StringWriter();
//            Marshaller marshaller = new Marshaller(xml);
//            marshaller.marshal(pic);
//            String myXmlString = xml.toString();
//            System.out.println(myXmlString);
//        }



    // System.out.println(tmp.getName());

    }
}
